import {
  MiddlewareConsumer,
  Module,
  NestModule,
  RequestMethod,
  Logger,
} from '@nestjs/common';
import { UserModule } from './users/user.module';
import { AppConfigModule } from './app.config';
import { DatabaseModule } from './app.database';
import { LoggerMiddleware } from './common/middleware/logger.middleware';
import { ServiceModule } from './service/service.module';
@Module({
  imports: [
    UserModule,
    AppConfigModule.forRoot(),
    DatabaseModule.forRootAsync(),
    ServiceModule,
  ],
  controllers: [],
  providers: [Logger],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(LoggerMiddleware)
      .forRoutes({ path: '*', method: RequestMethod.ALL });
  }
}
